package com.angel.web.health;


import org.springframework.stereotype.Controller;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.angel.core.util.FileUpload;
import com.angel.core.util.JsonUtil;

/**
 * @author cheng sir 2016年9月7日下午4:28:58
 */
@Controller
@RequestMapping("buzcpr")
public class CprController {

	@RequestMapping("uploadPage")
	public String uploadPage() {
		return "cpr";
	}

	/**
	 * 文件上传
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "uploadFile", produces = "application/json;charset=UTF-8")
	public String uploadTempAcceptance(MultipartHttpServletRequest request) {
		try {
			MultiValueMap<String, MultipartFile> multiFileMap = request.getMultiFileMap();
			String file = "e:\\文件上传";
			int upload = FileUpload.upload(multiFileMap, file);
			if (upload == 0) {
				return JsonUtil.toJson("文件格式不正确");
			}
		} catch (Exception e) {
			return JsonUtil.toJson(e.getMessage());
		}
		return JsonUtil.toJson("上传成功!");
	}
	
	/*public String readPdf(){
		List<String> list = new ArrayList<String>();
		try {
			*//**
			 * 不排序 读取pdf中体检结果上面的内容
			 * 若排序个人信息的表格中数据行不对
			 *//*
			String above = PDFUtils.getTextFromPdf("E:\\最新angel/陈祥君.pdf", false);
			String[] _above = above.split("\\r\\n");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}*/
}
